'''定子绕组直流电阻'''
def v1(x,y):
    vx=vy=0
    if 0<=x<=1:
        vx=0
    elif 1<x<=1.5:
        vx= 20 * ( (x-1) / (1-1.5) )
    elif 1.5<x<=3:
        vx= 20 + ( 40 - 20 ) * ( (x-1.5) / (3-1.5) )
    elif x>3:
        vx= 40


    if 0 <= y <= 1:
        vy = 0
    elif 1 < y <= 1.5:
        vy = 10 * ((y - 1) / (1 - 1.5))
    elif 1.5 < y <= 3:
        vy = 10+ (20 - 10) * ((y - 1.5) / (3 - 1.5))
    elif y > 3:
        vy = 20

    return (max(vx,vy))

#02.定子绕组交流耐压
def v2(x):
    pass

#03.定子绕组直流耐压
def v3(x):
    pass

#04.定子绕组泄露电流
def v4(x):
    pass

#05.定子绕组端部手包绝缘
def v5(x,y):
    vx=vy=0
    if 0<=x<=1500:
        vx=0
    elif 1500<x<=2000:
        vx=5*( (x-1500)/(2000-1500) )
    elif 1500<x<=3000:
        vx=5+(10-5)*((x-2000)/(3000-2000))
    elif x>3000:
        vx=10

    if 0<=y<=2500:
        vy=0
    elif 2500<y<3000:
        vy=5*((y-2500)/(3000-2500))
    elif 3000<y<=3500:
        vy=5+(10-5)*((y-3000)/(3500-3000))
    elif y>3500:
        vy=10
    return max(vx,vy)

#06.端部模态试验
def v6(x):
    pass

#07.防晕层检查及电晕试验
def v7(x):
    pass

#08.定子铁心试验
def v8(x):
    if 0<=x<=13.5:
        return 0
    elif 13.5<x<=15:
        return 10*((x-13.5)/(15-13.5))
    elif 15<x<=22.5:
        return 10+(20-10)*((x-15)/(22.5-13.5))
    elif x>22.5:
        return 20

#09.定子铁心检查
def v9(x):
    pass

#10.定子槽楔检查
def v10(x):
    pass

'''定子温度、温差'''
'''#################这个重要值窗口没有#######################'''
def v11(x1,x2,x3,x4,x5):
    vx1=vx2=vx3=vx4=vx5=0
    if 0<=x1<=7.5:
        vx1=0
    elif 7.5<x1<=8:
        vx1=10*((x1-7.5)/(8-7.5))
    elif 8<x1<=14:
        vx1=10+(40-10)*((x1-8)/(14-8))
    elif  x1>14:
        vx1=40

    if 0 <= x2 <= 7.5:
        vx2 = 0
    elif 7.5 < x2 <= 8:
        vx2 = 10 * ((x2 - 7.5) / (8 - 7.5))
    elif 8 < x2 <= 12:
        vx2 = 10 + (40 - 10) * ((x2 - 8) / (12 - 8))
    elif x2 > 12:
        vx2 = 40

    if 0<=x3<=85:
        vx3=0
    elif 85<x3<=90:
        vx3=40*((x3-85)/(90-85))
    elif x3>90:
        vx3=40

    if 0<=x4<=85:
        vx4=0
    elif 85<x4<=90:
        vx4=40*((x4-85)/(90-85))
    elif x4>90:
        vx4=40

    if 0<=x5<=110:
        vx5=0
    elif 110<x5<=120:
        vx5=15*((x5-110)/(120-110))
    elif 120<x5<=130:
        vx5=15+(30-15)*((x5-120)/(130-120))
    return max(vx1,vx2,vx3,vx4,vx5)

#在线监测
'''##################没有################################'''
def v12(x):
    pass

#发电机在线局部放电监测PDM
def v13(x):
    pass

#发电机绝缘过热检测
def v14(x):
    pass

#发电机噪音
def v15(x):
    pass

#发电机异音
def v16(x):
    pass

#发电机基座振动
def v17(x,y):
    '''x:刚性支撑结构；y: 弹性支持结构'''
    if x>20 or y >15:
        return 5
    else:
        return 0

'''转子绕组直流电阻'''
def v18(x):
    if 0<=x<=1.5:
        return 0
    elif 1.5<x<=2:
        return 10*((x-1.5)/(2-1.5))
    elif 2<x<=4:
        return 10+(40-10)*((x-2)/(4-2))
    elif x>4:
        return 40

#定转子绕组交流耐压
def v19(x):
    pass

#励滋回路所连接的设备的交流耐压
def v20(x):
    pass

#转子绕组绝缘电阻
def v21(x):
    if x<0.5:
        return 20
    else:
        return 0

#励滋回路所连接的设备的绝缘电阻
def v22(x):
    if x<0.5:
        return 20
    else:
        return 0

#交流阻抗
def v23(x):
    pass

#转子气密试验
def v24(x):
    pass

#转子通风试验
def v25(x):
    pass

#大轴、护环、风冷叶片金属表面探伤
def v26(x):
    pass

#发电机定转子间隙
def v27(x):
    pass

#集电环电刷装置检查
def v28(x):
    pass

'''转子接地报警信号'''
'''################重要但是没法写############'''
def v29(x):
    pass

#转子绕组匝间短路在线检测：
def v30(x):
    pass

'''集电环电刷装置运行'''
'''###############重要，部分要人工看'''
def v31(x):
    if x==0 or x=="off":
        return 40
    elif 0<x<=110:
        return 0
    elif 110<x<=120:
        return 20*((x-110)/(120-110))
    elif 120<x<=130:
        return 20+(40-20)*((x-120)/(130-120))
    elif x>130:
        return 40

#发电机轴承绝缘电阻及轴承电压
def v32(x,y):
    xv=vy=0
    if 0<=x<=0.3:
        vx=10
    elif 0.3<x<=0.5:
        vx=10-10*((x-0.3/0.2))
    elif x>0.5:
        vx=0

    if 0<=y<=10:
        vy=0
    elif 10<y<=20:
        vy=10*((y-10)/10)
    elif x>20:
        vy=10

    return max(vx,vy)

'''发电机轴承温度'''
'''##################重要但没有,并且预警温度t1,t2没给出##############'''
def v33(x,t1,t2):
    t1=t1-1
    t2=t2-1
    if 0<=x<=t1:
        return 0
    elif t1<x<=t2:
        return (40-10)*((x-t1)/(t2-t1))
    elif x>t2:
        return 40

'''发电机轴承振动'''
'''##################重要但没有,并且预警振动值，温度T1,T2,t1,t2没给出##############'''
def v34(x,y,t1,t2,T1,T2):
    t1=t1-1
    t2=t2-1
    T1=T1-5
    T2=T2-5
    vx=vy=0
    if 0<=x<=t1:
        vx=0
    elif t1<x<=t2:
        vx= (40-10)*((x-t1)/(t2-t1))
    elif x>t2:
        vx= 40

    if 0<=y<=T1:
        vy=0
    elif T1<y<=T2:
        vy= (40-10)*((y-T1)/(t2-T1))
    elif y>T2:
        vy= 40

#定子回路水压试验
def v35(x):
    pass

#定子线棒反冲洗
def v36(x):
    pass

#绝缘引水管检查
def v37(x):
    pass

#定冷水回路滤网检查
def v38(x):
    pass

#定冷水回路密封垫检查
def v39(x):
    pass

#定子线棒流量试验
def v40(x):
    pass

#氢冷器水压试验
def v41(x):
    pass

#密封瓦及轴颈检查
def v42(x):
    pass

#测温元件
'''############没有，一个坏了就扣2分##############'''
def v43(x):
    pass
#定冷水进水温度
'''############没有##############'''
def v44(x):
    pass

#定冷水流量
'''############没有##############'''
def v45(x):
    pass

#定冷水进出水压差
'''############没有##############'''
def v46(x):
    pass

##定冷水ph值
'''############没有##############'''
def v47(x1,x2,x3):
    '''缺少参数，不懂怎么评分'''

#定冷水铜离子含量
'''############没有##############'''
def v48(x1,x2):
    '''缺少参数，不懂怎么评分'''
    vx1=vx2=0
    if 0<=x1<=40:
        vx1=0
    elif 40<x1<=60:
        vx1=5*((x1-40)/20)
    elif 60<x1<=100:
        vx1=5+5*((x1-60)/40)
    elif x1>100:
        vx1=10

    if 0<=x2<=20:
        vx2=0
    elif 20<x2<=40:
        vx2=5*((x2-20)/20)
    elif 40<x2<=60:
        vx2=5+5*((x2-40)/20)
    elif x2>60:
        vx2=10
    return x1+x2

#定冷水电导率
'''############没有##############'''
def v49(x):
    pass

'''液位指示器检查'''
'''############没有，但是很重要,要人工评分##############'''
def v50(x):
    pass

#定氢气压力
'''############没有##############'''
def v51(x):
    pass

#冷氢温度
'''##############没有,且t1,t2没给#############'''
def v52(x,t1,t2):
    if 0<=x<=(t1-5):
        return 10
    elif t1-5<x<=t1:
        return 10*(abs(x-(t1-5))/5)
    elif t1<=x<=t2:
        return 0
    elif t2<x<=(t2+5):
        return 10*((x-t2)/5)
    elif x>(t2+5):
        return 10

'''氢气纯度'''
'''#################重要且没有########################'''
def v53(x):
    if 0<=x<=90:
        return 40
    elif 90<x<=96:
        return 40*((x-90)/6)
    elif x>96:
        return 0

#氢气露点温度
'''############没有##############'''
def v54(x,x1):
    '''x1:发电机内最低温度，x1发电机露点'''
    if x>=10 or 0<=x1<=25:
        return 10

'''发电机系统漏氢'''
'''############重要但是准么给，并且需要人工检查'''
def v55(x):
    pass

#密封油中含水量
def v56(x):
    '''mg/L'''
    if x>50 :
        return 5

#密封油温度
def v57(x):
    '''没参数'''
    pass

#氢油差压
def v58(x):
    '''没标准'''
    pass
